import requests
class DeptApi(object):
    def __init__(self):
        # 定义部门模块的url
        self.dept_url = "http://ihrm-java.itheima.net/api/company/department"

    # 封装部门列表
    def query_dept_list(self,headers):
        return requests.get(url=self.dept_url,headers=headers)

    # 封装获取部门信息(查询部门）
    def get_dept_detail(self,headers,dept_id):
        # 拼接查询部门信息的URL
        temp_url = self.dept_url + "/" + dept_id
        return requests.post(url=self.dept_url,headers=headers)

    # 封装添加部门接口
    def add_dept(self,headers,jaonData):
        return requests.post(url=self.dept_url,headers=headers,json=jaonData)

    # 封装修改部门
    def modify_dept(self,headers,jsonData,dept_id):
        return requests.put(url=self.dept_url + "/" + dept_id,
                            headers=headers,json=jsonData)

    # 封装删除部门
    def delete_dept(self,headers,dept_id):
        return requests.delete(url=self.dept_url + "/" +dept_id,
                               headers=headers)